package com.tianyang.yukuaifu.business.trade.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tianyang.yukuaifu.R;
import com.tianyang.yukuaifu.business.trade.bean.SubMerchantStatOutput;
import com.tianyang.yukuaifu.utils.DateUtils;
import com.tianyang.yukuaifu.utils.VerifyUtil;

import java.util.ArrayList;

/**
 * Description：商户详情统计
 * Created by xyj on 2024/3/26
 */
public class SubMerchantStatAdapter extends BaseQuickAdapter<SubMerchantStatOutput, BaseViewHolder> {

    public SubMerchantStatAdapter() {
        super(R.layout.item_sub_merchant_stat, new ArrayList<>());
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, SubMerchantStatOutput item) {
        if (item != null) {
            helper.setText(R.id.nameTv, VerifyUtil.checkString(item.getChannel()))
                    .setText(R.id.timeTv, "时间：" + DateUtils.formatTime(item.getCreateTime()))
                    .setText(R.id.amountTv, VerifyUtil.decimalFormat(item.getAmount()));
            ImageView payTypeIv = helper.getView(R.id.payTypeIv);
            if (TextUtils.equals("微信支付", item.getChannel())) {
                payTypeIv.setImageResource(R.drawable.ic_pay_wx);
            } else if (TextUtils.equals("支付宝", item.getChannel())) {
                payTypeIv.setImageResource(R.drawable.ic_pay_ali);
            } else {
                payTypeIv.setImageResource(R.drawable.ic_pay_union);
            }
        }
    }
}
